<?php
App::uses('AppModel', 'Model');
/**
 * Client Model
 *
 * @property Contact $Contact
 * @property Enquiry $Enquiry
 */
class Client extends AppModel {


/**
 * Validation rules
 *
 * @var array
 */
	public $validate = array(
		'username' => array(
			'notempty' => array(
				'rule' => array('notempty'),
                'message' => 'Please enter a username',
                'last' => false
			),
            'value' => array(
                'rule' => 'alphaNumeric',
                'message' => 'Cannot contain special characters',
                'last' => false
            ),
            'unique_name' => array(
                'rule' => 'isUnique',
                'message' => 'This username already exists',
                'last' => false
            )
		),
		'password' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
                'message' => 'Please enter a password',
                'last' => false
                //'allowEmpty' => false,
                //'message' => 'Your custom message here',
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
            'password_length' => array(
                'rule' => array('minLength',6),
                'message' => 'Minimum of 6 characters',
                'last' => false
            )
		),
		'surname' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
                'message' => 'Please enter your surname',
				'last' => false,
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
            'value' => array(
                'rule' => 'alphaNumeric',
                'message' => 'Cannot contain special characters',
                'last' => false
            )
		),
		'firstname' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
                'message' => 'Please enter your first name',
                'last' => false,
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
            'value' => array(
                'rule' => 'alphaNumeric',
                'message' => 'Cannot contain special characters',
                'last' => false
            )
		),
		'DOB' => array(
			'date' => array(
				'rule' => array('date'),
                'last' => false
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'mobile_num' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
                'message' => 'Please enter your mobile phone number',
                'last' => false
			),
            'number' => array(
                'rule' => 'numeric',
                'message' => 'Can only contain numbers',
                'last' => false
            ),
            'mobile_num_length' => array(
                'rule' => array('between',10,10),
                'message' => 'Must be 10 digits long e.g. 0412345678',
                'last' => false
            ),
		),
        'home_num' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'message' => 'Please enter your home phone number',
                'last' => false,
            ),
            'number' => array(
                'rule' => 'numeric',
                'message' => 'Can only contain numbers',
                'last' => false
            ),
            'home_num_length' => array(
                'rule' => array('between',8,8),
                'message' => 'Must be 8 digits long e.g. 98123456',
                'last' => false
            ),
        ),
        'work_num' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'message' => 'Please enter your work phone number',
                'last' => false
            ),
            'number' => array(
                'rule' => 'numeric',
                'message' => 'Can only contain numbers',
                'last' => false
            ),
            'work_num_length' => array(
                'rule' => array('between',8,10),
                'message' => 'Must be 8 to 10 digits long',
                'last' => false
            ),
        ),
        'email' => array(
            'email' => array(
                'rule' => array('email'),
                'message' => 'Invalid email address format',
                'last' => false
            ),
        ),
		'street' => array(
			'notEmpty' => array(
				'rule' => array('notempty'),
                'message' => 'Please enter your street address',
                'last' => false
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'city' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
                'message' => 'Please enter your suburb',
                'last' => false
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'postcode' => array(
            'notEmpty' => array(
                'rule' => array('notempty'),
                'message' => 'Please enter your postcode',
                'last' => false
            ),
			'numeric' => array(
                'rule' => array('numeric'),
                'message' => 'Can only contain 4 numbers'

			),
            'postcode_length' => array(
                'rule' => array('between',4,4),
                'message' => 'Can only contain 4 numbers'
            ),
		),
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * hasMany associations
 *
 * @var array
 */
	public $hasMany = array(
		'Contact' => array(
			'className' => 'Contact',
			'foreignKey' => 'client_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Enquiry' => array(
			'className' => 'Enquiry',
			'foreignKey' => 'client_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);

}
